// @lc code=start
/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

function ListNode(val) {
    this.val = val;
    this.next = null;
}

/**
 * @param {number[]} arr
 * @return {ListNode}
 */
function arrToList (arr) {
    let listNode = new ListNode(arr[0])
    let nowList = listNode
    for (let index = 1; index < arr.length; index++) {
        const element = arr[index];
        nowList.next = new ListNode(element)
        nowList = nowList.next
    }
    return listNode
}

/* 
    将题目中的数组转化成ListNode格式
    方便调试
    数组为空时不能保证转化的值正确
*/